/*
 * @Description: 浪潮导出酒店订单
 * @Version: 2.0
 * @Autor: 许国辉
 * @Date: 2023-05-19 08:24:06
 * @LastEditors: 许国辉
 * @LastEditTime: 2024-12-20 10:07:30
 */
import dayjs from 'dayjs';
import { BasicColumn } from '/@/components/Table';
function getDays(startDateString, endDateString) {
  const start = new Date(startDateString);
  const end = new Date(endDateString);
  const millisecondsPerDay = 1000 * 60 * 60 * 24;
  // 一天的毫秒数
  const millisecondsDiff = end.getTime() - start.getTime();
  // 获取毫秒差值
  const daysDiff = Math.ceil(millisecondsDiff / millisecondsPerDay);
  // 计算相差的天数
  return daysDiff;
}
export const comprehensiveHotelDataCoumns: BasicColumn[] = [
  {
    title: '终端类型',
    dataIndex: 'ZDLX',
    width: 80,
    customRender({ record }) {
      if (record.orderDetailDto.createBy === 'API接口') {
        return 'APP';
      } else {
        return '票务';
      }
    },
  },
  {
    title: '预订时间',
    dataIndex: 'createTime',
    customRender({ record }) {
      if (record.status === 'CANCEL')
        return dayjs(record.orderDetailDto.lastOptime).format('YYYY/MM/DD HH:mm:ss');
      else return dayjs(record.orderDetailDto.createTime).format('YYYY/MM/DD HH:mm:ss');
    },
    width: 180,
  },
  {
    title: '预订人',
    dataIndex: 'YDR',
    customRender({ record }) {
      return record.orderDetailDto.names;
    },
    width: 80,
  },
  {
    title: '出差申请单号',
    dataIndex: 'CCSQDH',
    customRender({ record }) {
      return record.voucherId;
    },
    width: 200,
  },
  {
    title: '订单号',
    dataIndex: 'DDH',
    customRender({ record }) {
      return record.orderId;
    },
    width: 200,
  },
  {
    title: '预订人编号',
    dataIndex: 'accountNo',
    width: 100,
  },
  {
    title: '出差人数',
    dataIndex: 'chucairenshu',
    width: 100,
    customRender: () => {
      return 1;
    },
  },
  {
    title: '入住人',
    dataIndex: 'names',
    width: 80,
  },
  {
    title: '联系人电话',
    dataIndex: 'mobile',
    customRender({ record }) {
      return record.orderDetailDto.contact.mobile;
    },
  },
  {
    title: '酒店名称',
    dataIndex: 'hotelName',
    customRender({ record }) {
      return record.orderDetailDto.hotelName;
    },
    width: 400,
  },
  {
    title: '城市',
    dataIndex: 'geoName',
    customRender({ record }) {
      return record.orderDetailDto.geoName;
    },
    width: 100,
  },
  {
    title: '入住日期',
    dataIndex: 'arrivalDate',
    width: 100,
    customRender({ record }) {
      return record.arrivalDate ? dayjs(record.arrivalDate).format('YYYY/MM/DD') : '-';
    },
  },
  {
    title: '离店日期',
    dataIndex: 'departureDate',
    width: 100,
    customRender({ record }) {
      return record.departureDate ? dayjs(record.departureDate).format('YYYY/MM/DD') : '-';
    },
  },
  {
    title: '房间数',
    dataIndex: 'roomCount',
    customRender({ record }) {
      return record.orderDetailDto.roomCount;
    },
    width: 60,
  },
  {
    title: '间夜数',
    dataIndex: 'jianyeshu',
    width: 60,
    customRender: ({ record }) => {
      return getDays(record.arrivalDate, record.departureDate);
    },
  },
  {
    title: '酒店级别',
    dataIndex: 'hotelLeave',
    width: 80,
    customRender: ({ record }) => {
      return record.orderDetailDto.assist.hotelCategory
        ? record.orderDetailDto.assist.hotelCategory
        : '-';
    },
  },
  {
    title: '房型',
    dataIndex: 'roomName',
    customRender({ record }) {
      return record.orderDetailDto.roomName;
    },
  },
  {
    title: '订单金额',
    dataIndex: 'money',
    customRender({ record }) {
      return record.status === 'CANCEL'
        ? -record.orderDetailDto.totalPay
        : record.orderDetailDto.totalPay;
    },
    width: 80,
  },
  {
    title: '日均价',
    dataIndex: 'priceAvg',
    width: 80,
    customRender: ({ record }) => {
      return record.status === 'CANCEL'
        ? (
            -record.orderDetailDto.totalPay / getDays(record.arrivalDate, record.departureDate)
          ).toFixed(2)
        : (
            record.orderDetailDto.totalPay / getDays(record.arrivalDate, record.departureDate)
          ).toFixed(2);
      // return record.orderDetailDto.totalPay / getDays(record.arrivalDate, record.departureDate);
    },
  },
  {
    title: '退款金额',
    dataIndex: 'TKJE',
    width: 80,
    customRender({ record }) {
      if (record.status === 'CANCEL') {
        return record.orderDetailDto.totalPay;
      } else {
        return '0';
      }
    },
  },
  {
    title: '增值费用',
    dataIndex: '1',
    width: 80,
    customRender({}) {
      return 0;
    },
  },
  {
    title: '其他费用',
    dataIndex: '2',
    width: 80,
    customRender({}) {
      return 0;
    },
  },
  {
    title: '房损金额',
    dataIndex: '3',
    width: 80,
    customRender({}) {
      return 0;
    },
  },
  {
    title: '取消订单费',
    dataIndex: '4',
    width: 80,
    customRender({}) {
      return 0;
    },
  },
  {
    title: '房费增加',
    dataIndex: '5',
    width: 80,
    customRender({}) {
      return 0;
    },
  },
  {
    title: '集团托管服务费',
    dataIndex: '6',
    width: 80,
    customRender({}) {
      return 0;
    },
  },
  {
    title: '单体托管服务费',
    dataIndex: '7',
    width: 80,
    customRender({}) {
      return 0;
    },
  },
  {
    title: '售票处服务费',
    dataIndex: '8',
    width: 80,
    customRender({}) {
      return 0;
    },
  },
  {
    title: '深白云 扣款',
    dataIndex: 'SBYKK',
    width: 110,
    customRender({ record }) {
      return record.status === 'CANCEL'
        ? -record.orderDetailDto.totalPay + record.amount
        : record.orderDetailDto.totalPay - record.amount;
    },
  },
  {
    title: '应收总计',
    dataIndex: 'YSZJ',
    width: 80,
    customRender({ record }) {
      return record.status === 'CANCEL'
        ? -record.orderDetailDto.totalPay
        : record.orderDetailDto.totalPay;
    },
  },
  {
    title: '总金额 包含服务费',
    dataIndex: 'ZJEBHFWD',
    customRender({ record }) {
      return record.status === 'CANCEL'
        ? -record.orderDetailDto.totalPay
        : record.orderDetailDto.totalPay;
    },
  },
  {
    title: '订单情况',
    dataIndex: 'DDQK',
    width: 100,
    customRender: ({ record }) => {
      if (record.status === 'WAIT_CONFIRM') {
        return '等待确认';
      } else if (record.status === 'WAIT_PAY') {
        return '等待支付';
      } else if (record.status === 'CONFIRM') {
        return '已确认';
      } else if (record.status === 'NO_SHOW') {
        return '未入住';
      } else if (record.status === 'CHECK_OUT') {
        return '已离店';
      } else if (record.status === 'CANCEL') {
        return '已取消';
      } else if (record.status === 'CHECK_IN	') {
        return '已入住';
      } else {
        return '无效';
      }
    },
  },
  {
    title: '渠道',
    dataIndex: 'channelName',
    customRender({ record }) {
      return record.orderDetailDto.channelName;
    },
  },
  {
    title: '提前离店/延住',
    dataIndex: '40',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '支付方式',
    dataIndex: 'payType',
    width: 100,
    customRender: ({ text }) => {
      if (text === 'SelfPay') {
        return '前台自付';
      } else {
        return '月结';
      }
    },
  },
  {
    title: '结算状态',
    dataIndex: '9',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '成本中心',
    dataIndex: 'costDeptName',
    customRender({ record }) {
      return record.orderDetailDto.customers[0].costDeptName
        ? record.orderDetailDto.customers[0].costDeptName
        : '-';
    },
  },
  {
    title: 'OA申请单号',
    dataIndex: 'voucherId',
    width: 200,
    customRender({ record }) {
      return record.voucherId ? record.voucherId : '-';
    },
  },
  {
    title: '业务经理',
    dataIndex: 'busiManage',
    width: 80,
    customRender({ record }) {
      return record.orderDetailDto.busiManage ? record.orderDetailDto.busiManage : '-';
    },
  },
  {
    title: '服务商名称',
    dataIndex: '10',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '供应商单号',
    dataIndex: 'GYSDH',
    customRender({ record }) {
      return record.orderDetailDto.serverId;
    },
  },
  {
    title: '订单状态',
    dataIndex: 'status',
    customRender: ({ text }) => {
      if (text === 'WAIT_CONFIRM') {
        return '等待确认';
      } else if (text === 'WAIT_PAY') {
        return '等待支付';
      } else if (text === 'CONFIRM') {
        return '已确认';
      } else if (text === 'NO_SHOW') {
        return '未入住';
      } else if (text === 'CHECK_OUT') {
        return '已离店';
      } else if (text === 'CANCEL') {
        return '已取消';
      } else if (text === 'CHECK_IN	') {
        return '已入住';
      } else {
        return '无效';
      }
    },
  },
  {
    title: '房损类型',
    dataIndex: '11',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '订单类型',
    dataIndex: 'DDLX',
    customRender() {
      return '国内酒店';
    },
  },
  {
    title: '预订人部门',
    dataIndex: 'YDRBM',
    customRender({ record }) {
      return record.departmentId;
    },
  },
  {
    title: '预订类型',
    dataIndex: 'travelType',
    width: 100,
    customRender: ({ text }) => {
      if (text === '0') {
        return '因公';
      } else {
        return '混合';
      }
    },
  },
  {
    title: '个人支付金额',
    dataIndex: 'amount',
    customRender({ record }) {
      if (record.amount != null) {
        return record.amount;
      }
    },
  },
  {
    title: '个人退款金额',
    dataIndex: 'refundAmount',
    customRender({ record }) {
      if (record.status === 'CANCEL') {
        return record.amount;
      } else {
        return '0';
      }
    },
  },
  {
    title: '公司支付金额',
    dataIndex: 'companyAmount',
    customRender({ record }) {
      return record.status === 'CANCEL' ? -record.companyAmount : record.companyAmount;
    },
  },
  {
    title: '公司退款金额',
    dataIndex: 'refundCompanyAmount',
    customRender({ record }) {
      return record.status === 'CANCEL' ? record.companyAmount : '0';
    },
  },
  {
    title: '交易流水号',
    dataIndex: 'serialNum',
    customRender({ record }) {
      return record.serialNum ? record.serialNum : '-';
    },
  },
  {
    title: '费用承担部门',
    dataIndex: '17',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '项目编号',
    dataIndex: '18',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '项目名称',
    dataIndex: '19',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '差旅事项',
    dataIndex: '20',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '超标原因',
    dataIndex: '21',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '超标金额',
    dataIndex: '22',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '超标描述',
    dataIndex: '23',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '费用类型',
    dataIndex: '24',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '差旅授权号',
    dataIndex: '25',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批状态',
    dataIndex: '26',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '给审批人留言',
    dataIndex: '27',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批组1类型',
    dataIndex: '28',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批组1审批人',
    dataIndex: '29',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批组2类型',
    dataIndex: '30',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批组2审批人',
    dataIndex: '31',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批组3类型',
    dataIndex: '32',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批组3审批人',
    dataIndex: '33',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批组4类型',
    dataIndex: '34',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '审批组4审批人',
    dataIndex: '35',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '入住人部门',
    dataIndex: 'RZRBM',
    customRender({ record }) {
      return record.departmentId;
    },
  },
  {
    title: '确认号',
    dataIndex: '36',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '酒店集团',
    dataIndex: '37',
    customRender({}) {
      return '-';
    },
  },
  {
    title: '差标金额',
    dataIndex: 'CBJE',
    customRender({ record }) {
      return record.standardPrice;
    },
  },
  {
    title: '消费记录id',
    dataIndex: 'recordId',
    customRender: ({ record }) => {
      return 'hotel' + record.id;
    },
  },
  // {
  //   title: '订单号',
  //   dataIndex: 'orderId',
  //   width: 180,
  // },
  {
    title: '入住人卡号',
    dataIndex: 'certNo',
    customRender({ record }) {
      return record.orderDetailDto.customers[0].certNo;
    },
    width: 200,
  },
];
